//src/stores/record.js
import { defineStore } from 'pinia';

export const recordStore = defineStore('recordStore', {
    state: () => ({
        recordId: null,
        patientId: null,
        isShow: false,
        visitCardId: null,
        name: null,
        phone: null,
        age: null,
        sex: null,
        imgDetail: [],
        bloodDrooping: [],
        probability: null,
        isUpdate: false,
        text: ''
    }),
    actions: {
        //清除病历信息
        clearRecordInfo() {
            this.recordId = null;
            this.patientId = null;
            this.visitCardId = null;
            this.isShow = false;
            this.name = null;
            this.phone = null;
            this.age = null;
            this.sex = null;
            this.text = '';
            this.imgDetail = [];
            this.bloodDrooping = [];
            this.probability = null;
            this.isUpdate = false;
        }
    },
    persist: {
        enabled: true, // 启用持久化
        storage: localStorage, // 使用 localStorage 存储
        paths: ['recordId', 'patientId', 'isShow', 'isUpdate', 'visitCardId', 'name', 'phone', 'age', 'sex', 'imgDetail', 'bloodDrooping', 'probability', 'text'] // 持久化所有字段
    }
}); 
